<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>controlP5 : : ScrollList</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="stylesheet.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
document.getElementsByTagName('html')[0].className = 'isjs';

function toggle(dt) 
{ 
  var display, dd=dt; 
  /* get dd */ 
  do{ dd = dd.nextSibling } while(dd.tagName!='DD'); 
  toOpen =!dd.style.display; 
  dd.style.display = toOpen? 'block':'' 
  dt.getElementsByTagName('span')[0].innerHTML 
    = toOpen? '-':'+' ; 
} 
</script>
</head>
<body>
<div id="container">
		<div id="header">
		<a href="./index.htm"><img src="./docuImages/title.jpg" /></a>
		</div>
	<div class="content">
		<h1>ScrollList</h1>
		<dl><dt class="key">description</dt><dd class="value"></dd></dl>
			
			<div class="toggleList example">
				<dl><dt onclick="toggle(this)"><span>+</span>Example</dt>
					<dd><pre>import controlP5.*;

ControlP5 controlP5;

ScrollList l;
void setup() {
  size(400,400);
  frameRate(30);
  controlP5 = new ControlP5(this);
  l = controlP5.addScrollList("myList",100,100,120,280);
  l.setLabel("something else");
  for(int i=0;i&lt;40;i++) {
    controlP5.Button b = l.addItem("a"+i,i);
    b.setId(100 + i);
  }
}

void controlEvent(ControlEvent theEvent) {
  // ScrollList is if type ControlGroup.
  // when an item in a scrollList is activated,
  // 2 controlEvents will be broadcasted.
  // the first one from the ScrollList, the second
  // one from the button that has been pressed
  // inside the scrollList.
  // to avoid an error message from controlP5, you
  // need to check what type of item triggered the
  // event, either a controller or a group.
  if(theEvent.isController()) {
    // an event from a controller e.g. button
    println(theEvent.controller().value()+" from "+theEvent.controller());
  } 
  else if (theEvent.isGroup()) {
    // an event from a group e.g. scrollList
    println(theEvent.group().value()+" from "+theEvent.group());
  }
}

void keyPressed() {
  if(key=='r') {
    l.removeItem("a"+int(random(40)) );
  } 
  else if(key=='a') {
    l.addItem("a"+int(random(40)), int(random(100)) );
  }
}
void draw() {
  background(0);
  // scroll the scroll List according to the mouseX position
  // when holding down SPACE.
  if(keyPressed && key==' ') {
    l.scroll(mouseX/((float)width)); // scroll taks values between 0 and 1
  }
}


</pre></dd>
				</dl>
			</div>
			
			
			
			<dl><dt class="key">constructors</dt><dd class="value"><pre></pre></dd></dl>
			
			
			
			
			
			
			
			<!-- METHODS:BEGIN -->
			
       <dl class="noborder"><dt>Methods</dt></dl>
       <dl><dt class="key"><a href="scrolllist_method_additem.htm">addItem ( )</a></dt><dd class="value">add an item to the scrollList.</dd></dl>
<dl><dt class="key"><a href="scrolllist_method_removeitem.htm">removeItem ( )</a></dt><dd class="value">remove an item from the scroll list.</dd></dl>
<dl><dt class="key"><a href="scrolllist_method_scroll.htm">scroll ( )</a></dt><dd class="value">scroll the scrollList remotely. values must range from 0 to 1.</dd></dl>

   
			<!-- METHODS:END -->
			<div class="separator">
			<dl><dt class="key">usage</dt><dd class="value">Web & Application</dd></dl>
			</div>
			<div class="separator">
			<dl><dt class="key">related</dt><dd class="value"><ul><li><a href="controller_class_controller.htm">Controller</a></li>
<li><a href="controlgroup_class_controlgroup.htm">ControlGroup</a></li>
<li><a href="controllergroup_class_controllergroup.htm">ControllerGroup</a></li>
</ul></dd></dl>
			</div>
	</div>
	<div id="footer">
	<p>by andreas schlegel (<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/" target="_blank">cc</a>) 2007, <a href="http://www.sojamo.de" target="_blank">sojamo</a>.</p>
	</div>
</div>
</body>
</html>


